package routers

import (
	"CMETO/controllers/fileController"
	middleware "CMETO/middlewares"

	"github.com/gin-gonic/gin"
)

func FileApi(r *gin.RouterGroup) {
	var file fileController.FileController
	var image fileController.ImageController
	var slice fileController.SliceFileUpload
	var upload fileController.UploadController
	fileRouter := r.Group("/file")
	{
		fileRouter.POST("/", file.SingleUpload)
		fileRouter.POST("/qiniu", file.SingleToQiNiu)
		fileRouter.GET("/qiniu", file.GetImages)
		fileRouter.DELETE("/", file.DeleteFile)
	}
	imageRouter := r.Group("/image", middleware.JWTAuthPlus())
	{
		imageRouter.GET("/", image.QueryImages)
		imageRouter.POST("/", image.AddImage)
		imageRouter.PUT("/", image.UpdateImage)
		imageRouter.DELETE("/", image.DeleteImages)
	}
	sliceRouter := r.Group("/slice")
	{
		sliceRouter.GET("/", slice.CheckStatus)
		sliceRouter.POST("/:index", slice.UploadSingleSlice)
		sliceRouter.GET("/merge", slice.MergeChunks)
	}
	uploadRouter := r.Group("/upload")
	{
		uploadRouter.POST("/", upload.FileUpload)
		uploadRouter.POST("/video", upload.VideoUpload)
	}
}
